﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Generic
{
    public class GenericClass<T>
    {
     
    }

    public class GenericClass<T,W>
    {

    }


    public class ChildClass<T, W> : GenericClass<T>, IGet<T> where W : Person,new()
    {
       private W w= new W() ;
        public void MyInterFace(T t)
        {
            Console.WriteLine("GenericClass W--This is {0},parameter={1},type={2}", typeof(GenericMethod), w.GetType().Name, w.ToString());
            Console.WriteLine("InterFace--This is {0},parameter={1},type={2}", typeof(GenericMethod), t.GetType().Name, t.ToString());
        }
    }

    //   这里继承的Class 和Interface   泛型的话只能用于 ChildClass  否则显性的给出类型  如：    public class ChildClass<T> : GenericClass<T,string>, IGet<T>
    // 错误写法    public class ChildClass<T> : GenericClass<T,W>, IGet<T>
    public class ChildClass<T> : GenericClass<T>, IGet<T>
    {
        public void MyInterFace(T t)
        {
            Console.WriteLine("InterFace--This is {0},parameter={1},type={2}", typeof(GenericMethod), t.GetType().Name, t.ToString());
        }
    }

    //    public class ChildClass : GenericClass<string>, IGet<T> 这种写法不支持
    //   这里继承的Class 和Interface   只能现行的给出 类型  
    public class ChildClass : GenericClass<string>, IGet<int>
    {
        public void MyInterFace(int t)
        {
            Console.WriteLine("InterFace--This is {0},parameter={1},type={2}", typeof(GenericMethod), t.GetType().Name, t.ToString());
        }
    }
    public interface IGet<T>
    {
        void MyInterFace(T t);
    }
}
